<template>
  <div>
    <div class="page">
      <div class="title">找回密码</div>
      <el-form :label-position="labelPosition" label-width="80px" :model="findpwdlist" :rules="rules" ref="findpwdlist">
        <el-form-item label="账户名">
          <el-input v-model="findpwdlist.username"></el-input>
        </el-form-item>
        <el-form-item label="手机号">
          <el-input v-model="findpwdlist.phone"></el-input>
        </el-form-item>
        <el-form-item label="验证码">
          <el-input v-model="findpwdlist.validation"></el-input>
        </el-form-item>

<el-form-item label="密码" prop="pass">
    <el-input type="password" v-model="findpwdlist.pass" autocomplete="off"></el-input>
  </el-form-item>
  <el-form-item label="确认密码" prop="checkPass">
    <el-input type="password" v-model="findpwdlist.checkPass" autocomplete="off"></el-input>
  </el-form-item>

      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Findpwd',
  data () {
    var validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'))
      } else {
        if (this.ruleForm2.checkPass !== '') {
          this.$refs.ruleForm2.validateField('checkPass')
        }
        callback()
      }
    }
    var validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'))
      } else if (value !== this.ruleForm2.pass) {
        callback(new Error('两次输入密码不一致!'))
      } else {
        callback()
      }
    }
    return {
      labelPosition: 'left',
      findpwdlist: {
        username: '',
        phone: '',
        validation: '',
        pass: '',
        checkPass: ''
      },
      rules: {
        pass: [
          { validator: validatePass, trigger: 'blur' }
        ],
        checkPass: [
          { validator: validatePass2, trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style scoped>
.page{
  padding: 30px  100px;
}
.title{
  height: 100px;
  background: #1296db;
  font-size: 60px;
  color: white;
  text-align: center;
  line-height: 100px;
  margin-bottom: 30px;
  border-radius: 10px;
}
</style>
